<%@ Import Namespace="System.Net" %>
<%@ Page Debug="true" %>

<Script runat="Server">
Private _cookieJar As CookieCollection

Public Sub Page_Load(sender As Object, e As EventArgs)
  Dim sessionExample As New SessionStateExample()
  Dim sessionCookie As Cookie
  Dim cookieContainer As New CookieContainer()
  Dim cookieCollection As New CookieCollection()

  sessionExample.CookieContainer = cookieContainer

  sessionCookie = CType(session("sessionCookie"), Cookie)

  If (IsNothing(sessionCookie)) Then
    sessionExample.SetSession("name", "rob")
    cookieCollection = sessionExample.CookieContainer.GetCookies(New Uri("http://localhost"))
    Session("sessionCookie") = cookieCollection("ASP.NET_SessionId")
  Else
    sessionExample.CookieContainer.Add(sessionCookie)
  End If
  
  lblSession1.Text = sessionExample.GetSession("name")
End Sub

</Script>
<Font face=arial>
Value: <asp:label id="lblSession1" runat="server"/>
</Font>